<?php
namespace app\admin\model;  
use think\Model;
use think\Db;  

class Paperdetail extends model
{
	protected $autoWriteTimestamp = 'datetime';
	protected $error = '';
	protected function initialize()
    {
        //需要调用`Model`的`initialize`方法
        parent::initialize();
        //TODO:自定义的初始化
    }
     /**
     * 保存试卷数据
     * @access public
     * @param array     $data  试卷基本信息
     * @param array     $datadetail  试卷详细信息
     * @return bool
     */
    public function saveDataDetail($datadetail){

        $num = Db::table('paperdetail')->insert($datadetail);
        return $num > 0 ? true : false;
    	
    }
    /**
     * 删除详细信息
     * @access public
     * @param $id
     * @return number
     */
    public function delDetail($id){
        $num = Db::table('paperdetail')->where('paperid',$id)->delete();
        return $num;
    }
    /**
     * 根据id查询信息
     * @access public
     * @param $id
     * @return array
     */
    public function getInfoById($id){
        $num = Db::table('paperdetail')
            ->where('paperid',$id)
            ->field('single,mul,ide,fill,judge,short')
            ->find();
        return $num;
    }

}
